package org.leetcode.easy.leetcode100;

import org.leetcode.TreeNode;

public class Solution
{
    public boolean isSameTree(TreeNode p, TreeNode q)
    {
        if (p==null && q!=null)
        {
            return false;
        }

        if (p==null && q==null)
        {
            return true;
        }

        if (p!=null && q==null)
        {
            return false;
        }

        if (p.val!=q.val)
        {
            return false;
        }

        boolean outside = isSameTree(p.left, q.left);
        boolean inside = isSameTree(p.right, q.right);

        return outside && inside;

    }
}
